//
//  CustomePickerImageVC.m
//  FangYunERP
//
//  Created by YuHuaMac on 2018/1/3.
//  Copyright © 2018年 YuHuaMac. All rights reserved.
//

#import "CustomePickerImageVC.h"

@interface CustomePickerImageVC ()

@end

@implementation CustomePickerImageVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
#pragma mark status bar style
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleDefault;
}

#pragma mark navigationBar tintColor & title textColor

- (instancetype)init {
    self = [super init];
    if (self) {
//        UIImage *navImage = [self imageWithColor:[UIColor colorWithRed:243/255.0 green:243/255.0 blue:243/255.0 alpha:1]];
//        self.navigationBar.tintColor = [UIColor whiteColor];
//        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, -20, kUIScreen.size.width, 20)];
//        imageView.image = navImage;
//        [self.navigationBar addSubview:imageView];
//        self.view.backgroundColor = [UIColor redColor];
//        [self.navigationBar setBackgroundImage:navImage forBarMetrics:UIBarMetricsDefault];
//        self.navigationBar.tintColor  = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1];
//        [self.navigationBar setTitleTextAttributes:@{
//                                                     UITextAttributeTextColor : [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1], UITextAttributeFont:[UIFont systemFontOfSize:17]
//                                                     }];

        [self.navigationBar setBackgroundImage:[self createImageWithColor:[UIColor colorWithRed:229/255.0 green:229/255.0 blue:229/255.0 alpha:1]] forBarMetrics:UIBarMetricsDefault];
        self.navigationBar.translucent = NO;
        [[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
        [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
        [self.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];
    }
    return self;
}
-(UIImage*) createImageWithColor:(UIColor*) color
{
    CGRect rect=CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return theImage;
}
- (UIImage *)imageWithColor:(UIColor *)color {
    CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    return image;
}
@end
